package com.fypg.module.medical.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fypg.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 医疗机构类型枚举
 */
@Getter
@AllArgsConstructor
public enum MedicalOrganizationTypeEnum implements ArrayValuable<String> {

    PENSION("Pension", "医养机构"),
    BLOOD_DONATION("BloodDonation", "献血点"),
    CHILD_CARE_AGENCY("ChildCareAgency", "备案托育机构"),
    FEVER("Fever", "发热门诊"),
    VACCINATION("Vaccination", "接种机构"),
    MIDWIFERY("Midwifery", "助产机构"),
    MOTHER_BABY("MotherBaby", "月子中心"),
    HOSPITAL("Hospital", "医疗机构"),
    AED("AED", "急救AED"),
    EMERGENCY("Emergency", "急救医院");

    public static final String[] ARRAYS = Arrays.stream(values()).map(MedicalOrganizationTypeEnum::getCode).toArray(String[]::new);

    @JsonValue
    private final String code;
    private final String description;

    @JsonCreator
    public static MedicalOrganizationTypeEnum fromCode(String code) {
        return Arrays.stream(MedicalOrganizationTypeEnum.values())
            .filter(e -> e.code.equalsIgnoreCase(code))
            .findFirst()
            .orElse(null);
    }

    @Override
    public String[] array() {
        return ARRAYS;
    }
}